package com.nineclock.system.controller;

import com.nineclock.common.entity.Result;
import com.nineclock.system.service.SmsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/sms")
public class SmsController {
    @Autowired
    private SmsService smsService;

    @GetMapping("/code")
    public Result getCode(@RequestParam("mobile") String mobile,@RequestParam("type") String type){
        smsService.getCode(mobile,type);
        return Result.success();
    }

    @GetMapping("/verify")
    public Result checkCode(@RequestParam("checkcode")String code,
                            @RequestParam("mobile") String mobile,
                            @RequestParam("type") String type){
        boolean result = smsService.checkCode(code,mobile,type);
        return Result.success(result);
    }
}
